﻿Imports MyPOSLibrary

Public Class MasterWindow
    Dim ConnectionString As String = My.Settings.DataConnectionString.ToString
    Private Sub MasterWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        If FormType = FormsList.None Then Me.Close()
        If FormType = FormsList.ClientList Then
            Dim ClientUCObject As New ClientEntryUserControl
            ClientUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Client Entry"
            MainStack.Children.Add(ClientUCObject)
        ElseIf FormType = FormsList.CompanyInfo Then
            Dim CompanyInfoUCObject As New CompanyInfoUserControl
            CompanyInfoUCObject.ConnectionString = ConnectionString
            CompanyInfoUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Company Info"
            MainStack.Children.Add(CompanyInfoUCObject)
        ElseIf FormType = FormsList.FinancialYear Then
            Dim FinYearUCObject As New FinYearUserControl
            FinYearUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Financial Year"
            MainStack.Children.Add(FinYearUCObject)
        ElseIf FormType = FormsList.ItemsList Then
            Dim ItemsUCObject As New ItemsUserControl
            ItemsUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Items"
            MainStack.Children.Add(ItemsUCObject)
        ElseIf FormType = FormsList.Ledgers Then
            Dim LedgerUCObject As New LedgerUserControl
            LedgerUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Ledgers"
            MainStack.Children.Add(LedgerUCObject)
        ElseIf FormType = FormsList.Lookup Then
            Dim LookupsUCObject As New LookupsUserControl
            LookupsUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Look-up"
            MainStack.Children.Add(LookupsUCObject)
        ElseIf FormType = FormsList.VendorList Then
            Dim VendorUCObject As New VendorUserControl
            VendorUCObject.Margin = New Thickness(10)
            ModuleNameRun.Text = "Vendors"
            MainStack.Children.Add(VendorUCObject)
        End If
    End Sub

    Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseDown
        DragMove()
    End Sub

    Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CloseButton.Click
        Me.Close()
    End Sub

    Private Sub MinimizeButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles MinimizeButton.Click
        Me.WindowState = Windows.WindowState.Minimized
    End Sub

    Public Property FormType As FormsList = FormsList.None

    Private Sub MasterSidePanel_CancelButtonClickEvent() Handles MasterSidePanel.CancelButtonClickEvent
        Me.Close()
    End Sub

    Private Sub MasterSidePanel_FindButtonClickEvent() Handles MasterSidePanel.FindButtonClickEvent
        Dim SearchWinObject As New SearchWindow
        SearchWinObject.ConnectionString = Me.ConnectionString
        SearchWinObject.FormType = FormType
        SearchWinObject.ShowDialog()
    End Sub
End Class
